import { request } from '@/utils/request'
import type { KnowledgeParams, PageParams, ConsultOrderPreParams, PartialConsult } from '@/types/consult'
export const getKnowledgePage = <T>(params: KnowledgeParams) =>
  request<T>('/patient/home/knowledge', 'GET', params)

// 推荐关注医生
export const getDoctorPage = <T>(params: PageParams) => request<T>('/home/page/doc', 'GET', params)
// 获取科室信息
export const getAllDep = <T>() => request<T>('/dep/all')

// 上传患者就诊图
export const uploadImage = <T>(file: File) => {
  const fd = new FormData()
  fd.append('file', file)
  return request<T>('/upload', 'POST', fd)
}
// 拉取预支付订单信息
export const getConsultOrderPre = <T>(params: ConsultOrderPreParams) =>
  request<T>('/patient/consult/order/pre', 'GET', params)

// 生成订单
export const createConsultOrder = (data: PartialConsult) =>
  request<{ id: string }>('/patient/consult/order', 'POST', data)

// 获取支付地址  0 是微信  1 支付宝
export const getConsultOrderPayUrl = (params: {
  paymentMethod: 0 | 1
  orderId: string
  payCallback: string
}) => request<{ payUrl: string }>('/patient/consult/pay', 'POST', params)

// 订单详情
export const getConsultOrderDetail = <T>(orderId: string) =>
  request<T>('/patient/consult/order/detail', 'GET', { orderId })
